package com.android.BluethootChess.connectivity;

import java.io.IOException;
import java.util.UUID;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothServerSocket;

import com.android.BluethootChess.util.Utils;

public class BluethootConnectivity {
	public BluethootConnectivity() {

		Utils.logFile("Start bluetooth");

		final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

		if (adapter == null) {
			Utils.logFile("No adapter");
		} else {
			Utils.logFile("Adapter value: " + adapter);
		}
		
		UUID myUID=UUID.randomUUID();
		try {
			BluetoothServerSocket sock=adapter.listenUsingRfcommWithServiceRecord("1", myUID);
			sock.accept();
		} catch (IOException e) {
			e.printStackTrace();
		}

		
/*		for (BluetoothDevice bd:adapter.getBondedDevices()){
			DataUtil.logFile("Device : "+bd.toString());
			DataUtil.logFile("Name: "+bd.getName()+"\n");
			try {
				sock=bd.createRfcommSocketToServiceRecord(myUID);
				sock.connect();
				sock.getOutputStream().write(1);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
*/		
		
		
/*		BluetoothDevice device=adapter.getRemoteDevice("16:45:4e:5d:00:00");
		DataUtil.logFile("Device "+device);
		
		
		UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
		try {
			BluetoothServerSocket sock=adapter.listenUsingRfcommWithServiceRecord("Sock", MY_UUID);
			DataUtil.logFile("BlueToothSocket: "+sock.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
*/
	}

	
}
